Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / app / src / main / java / com / geeksville / mesh / service / ReplyReceiver.kt

Displaying Raw • Download

app/src/main/java/com/geeksville/mesh/service/ReplyReceiver.kt 78274c792318331b11ab64cd28e58e829875b8c2 (78274c79) Text, 2.69 KB

T8b949e/*
* Copyright (c) 2025 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

Tff7b72package T7ee787com.geeksville.mesh.service

Tff7b72import T7ee787android.content.BroadcastReceiver
Tff7b72import T7ee787androidx.core.app.RemoteInput
Tff7b72import T7ee787dagger.hilt.android.AndroidEntryPoint
Tff7b72import T7ee787jakarta.inject.Inject
Tff7b72import T7ee787org.meshtastic.core.model.DataPacket
Tff7b72import T7ee787org.meshtastic.core.service.MeshServiceNotifications
Tff7b72import T7ee787org.meshtastic.core.service.ServiceRepository

T8b949e/**
* A [BroadcastReceiver] that handles inline replies from notifications.
*
* This receiver is triggered when a user replies to a message directly from a notification. It extracts the reply text
* and the contact key from the intent, sends the message using the [ServiceRepository], and then cancels the original
* notification.
*/
Tf0883e@AndroidEntryPoint
Tff7b72class T56d364ReplyReceiver Tb4b4b4: Te6edf3BroadcastReceiverTb4b4b4(Tb4b4b4) Tb4b4b4{
Tf0883e@Inject Tff7b72lateinit Tff7b72var Te6edf3serviceRepositoryTb4b4b4: Te6edf3ServiceRepository

Tf0883e@Inject Tff7b72lateinit Tff7b72var Te6edf3meshServiceNotificationsTb4b4b4: Te6edf3MeshServiceNotifications

Tff7b72companion Tff7b72object Tb4b4b4{
Tff7b72const Tff7b72val Te6edf3REPLY_ACTION Tff7b72= Ta5d6ff"Ta5d6ffcom.geeksville.mesh.REPLY_ACTIONTa5d6ff"
Tff7b72const Tff7b72val Te6edf3CONTACT_KEY Tff7b72= Ta5d6ff"Ta5d6ffcontactKeyTa5d6ff"
Tff7b72const Tff7b72val Te6edf3KEY_TEXT_REPLY Tff7b72= Ta5d6ff"Ta5d6ffkey_text_replyTa5d6ff"
Tb4b4b4}

Tff7b72private Tff7b72fun Td2a8ffsendMessageTb4b4b4(Te6edf3strTb4b4b4: Tffa657StringTb4b4b4, Te6edf3contactKeyTb4b4b4: Tffa657String Tff7b72= Ta5d6ff"Ta5d6ff0Tffd700${Te6edf3DataPacketTb4b4b4.Te6edf3ID_BROADCASTTffd700}Ta5d6ff"Tb4b4b4) Tb4b4b4{
T8b949e// contactKey: unique contact key filter (channel)+(nodeId)
Tff7b72val Te6edf3channel Tff7b72= Te6edf3contactKeyTff7b72[T79c0ff0Tff7b72]Tb4b4b4.Te6edf3digitToIntOrNullTb4b4b4(Tb4b4b4)
Tff7b72val Te6edf3dest Tff7b72= Tff7b72if Tb4b4b4(Te6edf3channel Tff7b72!Tff7b72= Tff7b72nullTb4b4b4) Te6edf3contactKeyTb4b4b4.Te6edf3substringTb4b4b4(T79c0ff1Tb4b4b4) Tff7b72else Te6edf3contactKey
Tff7b72val Te6edf3p Tff7b72= Te6edf3DataPacketTb4b4b4(Te6edf3destTb4b4b4, Te6edf3channel Tff7b72?: T79c0ff0Tb4b4b4, Te6edf3strTb4b4b4)
Te6edf3serviceRepositoryTb4b4b4.Te6edf3meshServiceTff7b72?.Te6edf3sendTb4b4b4(Te6edf3pTb4b4b4)
Tb4b4b4}

Tff7b72override Tff7b72fun Td2a8ffonReceiveTb4b4b4(Te6edf3contextTb4b4b4: Te6edf3androidTb4b4b4.Te6edf3contentTb4b4b4.Te6edf3ContextTb4b4b4, Te6edf3intentTb4b4b4: Te6edf3androidTb4b4b4.Te6edf3contentTb4b4b4.Te6edf3IntentTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3remoteInput Tff7b72= Te6edf3RemoteInputTb4b4b4.Te6edf3getResultsFromIntentTb4b4b4(Te6edf3intentTb4b4b4)

Tff7b72if Tb4b4b4(Te6edf3remoteInput Tff7b72!Tff7b72= Tff7b72nullTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3contactKey Tff7b72= Te6edf3intentTb4b4b4.Te6edf3getStringExtraTb4b4b4(Te6edf3CONTACT_KEYTb4b4b4) Tff7b72?: Ta5d6ff"Ta5d6ff"
Tff7b72val Te6edf3message Tff7b72= Te6edf3remoteInputTb4b4b4.Te6edf3getCharSequenceTb4b4b4(Te6edf3KEY_TEXT_REPLYTb4b4b4)Tff7b72?.Te6edf3toStringTb4b4b4(Tb4b4b4) Tff7b72?: Ta5d6ff"Ta5d6ff"
Te6edf3sendMessageTb4b4b4(Te6edf3messageTb4b4b4, Te6edf3contactKeyTb4b4b4)
Te6edf3MeshServiceNotificationsImplTb4b4b4(Te6edf3contextTb4b4b4)Tb4b4b4.Te6edf3cancelMessageNotificationTb4b4b4(Te6edf3contactKeyTb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.05s